import java.util.Stack;



    public class minstack {
        public Stack<Integer> m ;

        public Stack<Integer> s ;

        public minstack() {
            s =  new Stack<Integer>();
            m =  new Stack<Integer>();

        }

        public void push(int val) {
            s.push(val);
            if (m.empty()) {
                m.push(val);
            } else {
                int p = m.peek();
                if (val <= p) {
                    m.push(val);
                }
            }

        }

        public void pop() {
            if (s.empty()) {
                return;
            }
            int p = s.pop();
            if (p == m.peek()) {
                m.pop();
            }

        }

        public int top() {
            if (s.empty()) {
                return -1;
            }
            return s.peek();



        }

        public int getMin() {
            if (m.empty()) {
                return -1;
            }
            return m.peek();


        }
    }

